package com.vedana.bankmobile.protobuf;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Basic protobuf RPC servlet
 * 
 * @author Didier MOISE
 *
 */
public class BankMobileProtoServlet extends HttpServlet {
	private static final long serialVersionUID = 3190031067195653802L;

	  private BankMobileProtoHandler _handler = new BankMobileProtoHandler(); 

	  /**
	  * Default constructor. 
	  */
	  public BankMobileProtoServlet ()
	  {
	  }

	  /**
	   * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	   */
	  protected void doGet (HttpServletRequest request, HttpServletResponse response)
	      throws ServletException, IOException
	  {
	    doIt(request, response);
	  }

	  /**
	   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	   */
	  protected void doPost (HttpServletRequest request, HttpServletResponse response)
	      throws ServletException, IOException
	  {
	    doIt(request, response);
	  }

	  private void doIt (HttpServletRequest request, HttpServletResponse response)
	      throws ServletException, IOException
	  {
	    _handler.handle(response.getOutputStream(), request.getInputStream());
	  }
}
